package com.biqee.dao.impl;

import java.util.HashMap;
import java.util.Map;

import com.biqee.dao.BqUserDAO;
import com.biqee.dao.base.BaseDAOImpl;
import com.biqee.model.db.BqUser;

public class BqUserDAOImpl extends BaseDAOImpl implements BqUserDAO {

	@Override
	public BqUser readByLoginName(String loginName) {
		return (BqUser)getSqlMapClientTemplate().queryForObject(getRealSqlId("readByLoginName"), loginName);
	}

	@Override
	public BqUser readById(Long id) {
		return (BqUser)getSqlMapClientTemplate().queryForObject(getRealSqlId("readById"), id);
	}

	@Override
	public Long create(BqUser bqUser) {
		return (Long)getSqlMapClientTemplate().insert(getRealSqlId("create"), bqUser);
	}

	@Override
	public int updatePassword(Long id, String password) {
		Map<String, Object> condition = new HashMap<String, Object>();
		condition.put("id", id);
		condition.put("password", password);
		
		return (Integer)getSqlMapClientTemplate().update(getRealSqlId("updatePassword"), condition);
	}


}